导航菜单
首页 >  HTML img src image source with path options 5 examples  > [HTML] how to load local image by html output · Issue #884 · gradio

[HTML] how to load local image by html output · Issue #884 · gradio

Hi @snapfast, thank you for your prompt response!

I tested the solution you provided, but I found a quicker workaround in my case. It appears that .svg images don't render properly for me, while .png images work flawlessly.

For instance, the following code doesn't display the image as expected:

import gradio as grwith gr.Blocks() as demo:gr.HTML("")demo.launch()

However, switching to .png works without any issues:

import gradio as grwith gr.Blocks() as demo:gr.HTML("")demo.launch()

Additionally, I noticed that I don't need to set allowed_paths for this to work locally. It seems like this configuration becomes necessary only when deploying the app behind a reverse proxy, such as nginx.

@abidlabs, it would be extremely helpful if the documentation could include a brief guide on serving HTML resources, especially clarifying the behavior with different image formats and deployment scenarios.

Thanks a lot again for your help, and I just want to add that I really enjoy working with Gradio. It's an amazing tool!

相关推荐: